home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Interfaces & Libraries / Interfaces / CIncludes / fcntl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-05  |  4.9 KB  |  153 lines  |  [TEXT/MPS ]

  1. /************************************************************
  2.  
  3.     FCntl.h
  4.     faccess(), fcntl(), and open() mode flags.
  5.  
  6.     Copyright Apple Computer,Inc.  1995
  7.     All rights reserved
  8.  
  9.  * Warning:  This interface is NOT a part of the ANSI C standard.
  10.  *           This header file is not POSIX compliant.
  11.  *           For portable code, don't use this interface.
  12.  
  13. ************************************************************/
  14.  
  15.  
  16. #ifndef __FCNTL__
  17. #define __FCNTL__
  18.  
  19.  
  20. /*
  21.  * Get common declarations 
  22.  */
  23.  
  24. #include <SeekDefs.h>
  25. #include <SizeTDef.h>
  26.  
  27.  
  28. /*
  29.  * faccess() commands; for general use
  30.  */
  31.                        /* 'd' => "directory" ops */
  32. #define F_DELETE        (('d'<<8)|0x01)
  33. #define F_RENAME        (('d'<<8)|0x02)
  34.  
  35. /*
  36.  * more faccess() commands; for use only by MPW tools
  37.  */
  38.  
  39. #define F_OPEN          (('d'<<8)|0x00)     /* reserved for operating system use  */
  40.                        /* 'e' => "editor" ops */
  41. #define F_GTABINFO      (('e'<<8)|0x00)     /* get tab offset for file            */
  42. #define F_STABINFO      (('e'<<8)|0x01)     /* set  "   "      "   "              */
  43. #define F_GFONTINFO     (('e'<<8)|0x02)     /* get font number and size for file  */
  44. #define F_SFONTINFO     (('e'<<8)|0x03)     /* set  "     "     "   "    "   "    */
  45. #define F_GPRINTREC     (('e'<<8)|0x04)     /* get print record for file          */
  46. #define F_SPRINTREC     (('e'<<8)|0x05)     /* set   "     "     "   "            */
  47. #define F_GSELINFO      (('e'<<8)|0x06)     /* get selection information for file */
  48. #define F_SSELINFO      (('e'<<8)|0x07)     /* set     "          "       "   "   */
  49. #define F_GWININFO      (('e'<<8)|0x08)     /* get current window position        */
  50. #define F_SWININFO      (('e'<<8)|0x09)     /* set    "      "       "            */
  51. #define F_GSCROLLINFO   (('e'<<8)|0x0A)     /* get scroll information             */
  52. #define F_SSCROLLINFO   (('e'<<8)|0x0B)     /* set    "        "                  */
  53. #define F_GMARKER       (('e'<<8)|0x0D)     /* Get Marker                         */
  54. #define F_SMARKER       (('e'<<8)|0x0C)     /* Set   "                            */
  55. #define F_GSAVEONCLOSE  (('e'<<8)|0x0F)     /* Get Save on close                  */
  56. #define F_SSAVEONCLOSE  (('e'<<8)|0x0E)     /* Set  "   "    "                    */
  57.  
  58. /*
  59.  *  argument structure for use with F_SMARKER command
  60.  */
  61. #ifdef powerc
  62. #pragma options align=mac68k
  63. #endif
  64. struct MarkElement {
  65.     int             start;          /* start position of mark */
  66.     int             end;            /* end position */
  67.     unsigned char   charCount;      /* number of chars in mark name */
  68.     char            name[64];       /* marker name */
  69. };                                  /* note: marker may be up to 64 chars long */
  70.  
  71. #ifdef powerc
  72. #pragma options align=reset
  73. #endif
  74.  
  75. #ifndef __cplusplus
  76. typedef struct MarkElement MarkElement;
  77. #endif
  78.  
  79. #ifdef powerc
  80. #pragma options align=mac68k
  81. #endif
  82. struct SelectionRecord {
  83.     long    startingPos;
  84.     long    endingPos;
  85.     long    displayTop;
  86. };
  87. #ifdef powerc
  88. #pragma options align=reset
  89. #endif
  90. #ifndef __cplusplus
  91. typedef struct SelectionRecord SelectionRecord;
  92. #endif
  93.  
  94.  
  95. /*
  96.  * Mode values accessible to open()
  97.  */
  98.  
  99. #define O_RDONLY      0x00      /* Open for reading only.            */
  100. #define O_WRONLY      0x01      /* Open for writing only.            */
  101. #define O_RDWR        0x02      /* Open for reading & writing.       */
  102. #define O_APPEND      0x08      /* Write to the end of the file.     */
  103. #define O_RSRC        0x10      /* Open the resource fork.           */
  104. #define O_ALIAS       0x20      /* Open alias file.                  */
  105. #define O_CREAT      0x100      /* Open or create a file.            */
  106. #define O_TRUNC      0x200      /* Open and truncate to zero length. */
  107. #define O_EXCL       0x400      /* Create file only; fail if exists. */
  108. #define O_BINARY     0x800      /* Open as a binary stream.          */
  109. #define O_NRESOLVE  0x4000      /* Don't resolve any aliases.        */
  110.  
  111. /*
  112.  * fcntl() commands
  113.  */
  114. #define F_DUPFD 0      /* Duplicate files (file descriptor) */
  115.  
  116.  
  117. typedef int ssize_t;
  118. typedef long off_t;
  119.  
  120. #if defined (__CFM68K__) && !defined (UsingStaticLibs)
  121.     #pragma import on
  122. #endif
  123.  
  124. #if __cplusplus
  125. extern "C" {
  126. #endif  /* __cplusplus */
  127.  
  128. /*
  129.  * Input and Output Primitives 
  130.  */
  131.  
  132. extern int open(const char *path, int oflag);
  133. extern int creat(const char *path);
  134. extern int unlink(char *path);
  135. extern int faccess(char *path, unsigned int cmd, long *arg);
  136. extern int dup(int fildes);     /* OBSOLETE: fcntl(filedes, F_DUPFD, 0) is preferred. */
  137. extern int close(int fildes);
  138. extern ssize_t read(int fildes, void *buf, size_t nbyte);
  139. extern ssize_t write(int fildes, const void *buf, size_t nbyte);
  140. extern int fcntl(int fildes, unsigned int cmd, int arg);
  141. extern off_t lseek(int fildes, off_t offset, int whence);
  142.  
  143.  
  144. #if __cplusplus
  145. }
  146. #endif  /* __cplusplus */
  147.  
  148. #if defined (__CFM68K__) && !defined (UsingStaticLibs)
  149.     #pragma import off
  150. #endif
  151.  
  152. #endif  /* __FCNTL__ */
  153.